#pragma once

#include "string"
using namespace std;


class WStringAssist{
public:
	static wstring Lower(wstring str){
		const wchar_t* ch = str.c_str();
		int iLen = str.size() + 1;
		wchar_t *wbuf = new wchar_t[iLen];
		for(int i = 0; i < iLen - 1; ++ i){
			if(ch[i] <= 'Z' && str.at(i) >= 'A'){
				wbuf[i] = ch[i]  + ('a' - 'A');
			}
			else{
				wbuf[i] = ch[i];
			}
		}
		wbuf[iLen - 1] = 0;
		wstring ret;
		ret = wbuf;
		delete[] wbuf;
		return ret;
	}

	static BOOL IsXML(LPCTSTR lpszPathName){
		if(wcslen(lpszPathName) < 5) return false;
		wstring strPathName(lpszPathName);
		wstring strExtension  = strPathName.substr(strPathName.size() - 3, 3);
		strExtension = Lower(strExtension);
		if(strExtension == L"pro")
			return true;
		return false;
	}

	static BOOL IsASM(LPCTSTR lpszPathName){
		if(wcslen(lpszPathName) < 5) return false;
		wstring strPathName(lpszPathName);
		if(strPathName.at(strPathName.length() - 4) != L'.') return false;
		wstring strExtension  = strPathName.substr(strPathName.size() - 3, 3);
		strExtension = Lower(strExtension);
		if(strExtension == L"asm")
			return true;
		return false;
	}

	static BOOL IsMacro(LPCTSTR lpszPathName){
		if(wcslen(lpszPathName) < 5) return false;
		wstring strPathName(lpszPathName);
		if(strPathName.at(strPathName.length() - 4) != L'.') return false;
		wstring strExtension  = strPathName.substr(strPathName.size() - 3, 3);
		strExtension = Lower(strExtension);
		if(strExtension == L"inc")
			return true;
		return false;
	}
};